package ch.bfh.abhmcm.SoftwareEngineeringAndDesign.view.mainframe.acceptRFCPanel.acceptRFCPanelSubs;

import java.awt.BorderLayout;
import java.awt.Font;
import java.awt.GridLayout;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;

import ch.bfh.abhmcm.SoftwareEngineeringAndDesign.view.mainframe.acceptRFCPanel.AcceptRFCPanel;
import ch.bfh.abhmcm.SoftwareEngineeringAndDesign.view.mainframe.acceptRFCPanel.acceptRFCPanelSubs.listeners.OpenRFCButtonListener;
import ch.bfh.abhmcm.SoftwareEngineeringAndDesign.view.mainframe.mainframeSub.RFCDisplayTable;

public class AcceptListPanel extends JPanel {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private RFCDisplayTable approvedDisplayTable;
	private RFCDisplayTable workingDisplayTable;
	private AcceptRFCPanel acceptRFCPanel;

	public AcceptListPanel(AcceptRFCPanel acceptRFCPanel) {

		this.setLayout(new BorderLayout());
		this.acceptRFCPanel = acceptRFCPanel;
		this.approvedDisplayTable = new RFCDisplayTable(true);
		this.workingDisplayTable = new RFCDisplayTable(true);
		this.add(new Layouthelper(), BorderLayout.CENTER);

	}

	public RFCDisplayTable getApprovedDisplayTable() {
		return approvedDisplayTable;
	}

	public RFCDisplayTable getWorkingDisplayTable() {
		return workingDisplayTable;
	}

	private class Layouthelper extends JPanel {

		/**
		 * 
		 */
		private static final long serialVersionUID = 1L;

		private Layouthelper() {

			this.setLayout(new GridLayout(2, 1));
			
			Font font = new Font("marker", Font.BOLD, 12);

			JLabel l1 = new JLabel(" Ihnen zugewiesene Workorders:");
			l1.setFont(font);
			approvedDisplayTable.addMouseListener(new OpenRFCButtonListener(acceptRFCPanel));
			this.add(new ListPanel(l1, approvedDisplayTable));

			JLabel l2 = new JLabel(" Workorders die zurzeit von Ihnen bearbektet werden: ");
			l2.setFont(font);
			
			workingDisplayTable.addMouseListener(new OpenRFCButtonListener(acceptRFCPanel));
			this.add(new ListPanel(l2, workingDisplayTable));

		}
	}

	private class ListPanel extends JPanel {

		/**
		 * 
		 */
		private static final long serialVersionUID = 1L;

		private ListPanel(JLabel label, RFCDisplayTable displayTable) {

			this.setLayout(new BorderLayout());

			this.add(label, BorderLayout.NORTH);
			JScrollPane scrollPane = new JScrollPane(displayTable);
			this.add(scrollPane, BorderLayout.CENTER);
		}
	}
}
